/**
 * 获取元素距离body的上偏移和左偏移
 * 同理元素elem距离其relative父元素div的左偏移为elem.getBoundingClientRect().left + div.scrollLeft - div.getBoundingClientRect().left
 */
const axOffset = (elem) => {
    let totalLeft,
        totalTop,
        scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft,
        scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    totalLeft = elem.getBoundingClientRect().left + scrollLeft;
    totalTop = elem.getBoundingClientRect().top + scrollTop;
    return {
        left: totalLeft,
        top: totalTop
    }
}